from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC


class UploadFilePage():

    def __init__(self, driver):
        self.driver = driver
        # 网址
        # self.url = "http://localhost:8080/myupload"
        self.url = "http://wj53793py34.vicp.fun/myupload"
        # 控件xpath
        self.upload_file_input_xpath = "//input[@name='file']"
        self.alert_xpath = "//p[text()='上传文件成功']"


    # 获取上传控件
    @property
    def upload_file_input_ele(self):
        wait = WebDriverWait(self.driver, 10)
        upload_file_input = wait.until(EC.presence_of_element_located((By.XPATH, self.upload_file_input_xpath)))
        return upload_file_input

    # 获取提示信息
    @property
    def alert_ele(self):
        wait = WebDriverWait(self.driver, 10)
        alert = wait.until(EC.visibility_of_element_located((By.XPATH, self.alert_xpath)))
        return alert